using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for List
/// </summary>
public class List
{
	public List()
	{
		//
		// TODO: Add constructor logic here
		//
	}


    public string GetListSelections(System.Web.UI.WebControls.ListControl list, string collectValueOrText)
    {
        ListItemCollection ListItems = list.Items;
        string SelectedItems = "";
        foreach (ListItem itm in ListItems)
        {
            if (itm.Selected)
            {
                if (collectValueOrText.ToLower() == "value")
                    SelectedItems += itm.Value + ", ";

                else
                    SelectedItems += itm.Text + ", ";
            }
        }
        if (SelectedItems.Length > 0)
        {
            SelectedItems = SelectedItems.Substring(0, SelectedItems.Length - 2);//remove trailing ", "
        }
        return SelectedItems;
    }
}
